package com.pagoda.nerp.trade.app.account.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

public class ParamsCheck {

	public static String checkWxBlindState(Map map) {
		StringBuffer missSb = new StringBuffer();
		StringBuffer invalidSb = new StringBuffer();
		if (null == map.get("openId")) {
			missSb.append("openId");
		}else if (StringUtils.isBlank((String)map.get("openId"))) {
			invalidSb.append("openId={"+(String)map.get("openId")+"}");
		}
		
		
		String result="";
		if (missSb.length() >0) {
			result+= "缺失参数:"+missSb.toString()+". ";
		}

		if (invalidSb.length() >0) {
			result+= "无效的参数:"+invalidSb.toString();
		}
		return result;
	}
	
	public static String checkRegister(Map map) {
		StringBuffer missSb = new StringBuffer();
		StringBuffer invalidSb = new StringBuffer();
		if (null == map.get("vendorName")) {
			missSb.append("vendorName | ");
		}else if (StringUtils.isBlank((String)map.get("vendorName"))) {
			invalidSb.append("vendorName={"+(String)map.get("vendorName")+"},");
		}
		
		if (null == map.get("customerKind")) {
			missSb.append("customerKind |");
		}else if (StringUtils.isBlank((String)map.get("customerKind"))) {
			invalidSb.append("customerKind={"+(String)map.get("customerKind")+"},");
		}
		
		if (null == map.get("contacts")) {
			missSb.append("contacts | ");
		}else if (StringUtils.isBlank((String)map.get("contacts"))) {
			invalidSb.append("contacts={"+(String)map.get("contacts")+"},");
		}
		
		if (null == map.get("phoneNumber")) {
			missSb.append("phoneNumber | ");
		}else if (StringUtils.isBlank((String)map.get("phoneNumber"))) {
			invalidSb.append("phoneNumber={"+(String)map.get("phoneNumber")+"},");
		}
		
		if (null == map.get("verifyCode")) {
			missSb.append("verifyCode | ");
		}else if (StringUtils.isBlank(map.get("verifyCode").toString())) {
			invalidSb.append("verifyCode={"+map.get("verifyCode").toString()+"},");
		}
		
		if (null == map.get("openId"))  {
			missSb.append("openId | ");
		}else if (StringUtils.isBlank(map.get("openId").toString())) {
			invalidSb.append("openId={"+map.get("openId").toString()+"},");
		}
		
		if (null == map.get("organizationCode")&&null == map.get("cardNo")) {
			missSb.append("organizationCode | cardNo");
		}
		
		String result="";
		if (missSb.length() >0) {
			result+= "缺失参数:"+missSb.toString()+". ";
		}
		
		if (invalidSb.length() >0) {
			result+= "无效的参数:"+invalidSb.toString();
		}
		return result;
	}
	public static String checkLogin(Map map) {
		StringBuffer missSb = new StringBuffer();
		StringBuffer invalidSb = new StringBuffer();
		if (null == map.get("account")) {
			missSb.append("account | ");
		}else if (StringUtils.isBlank(map.get("account").toString())) {
			invalidSb.append("account={"+map.get("account").toString()+"},");
		}
		
		if (null == map.get("verifyCode")) {
			missSb.append("verifyCode | ");
		}else if (StringUtils.isBlank(map.get("verifyCode").toString())) {
			invalidSb.append("verifyCode={"+map.get("verifyCode").toString()+"},");
		}
		
		if (null == map.get("openId")) {
			missSb.append("openId");
		}else if (StringUtils.isBlank(map.get("openId").toString())) {
			invalidSb.append("openId={"+map.get("openId").toString()+"}");
		}
		
		String result="";
		if (missSb.length() >0) {
			result+= "缺失参数:"+missSb.toString()+". ";
		}
		
		if (invalidSb.length() >0) {
			result+= "无效的参数:"+invalidSb.toString();
		}
		return result;
	}
	
	public static String checkAccount(Map map) {
		StringBuffer missSb = new StringBuffer();
		StringBuffer invalidSb = new StringBuffer();
		if (null == map.get("accountType")) {
			missSb.append("accountType | ");
		}else if (StringUtils.isBlank(map.get("accountType").toString())) {
			invalidSb.append("accountType={"+(String)map.get("accountType")+"},");
		}
		
		if (null == map.get("accountId")) {
			missSb.append("accountId | ");
		}else if (StringUtils.isBlank(map.get("accountId").toString())) {
			invalidSb.append("accountId={"+(String)map.get("accountId")+"}");
		}
		
		String result="";
		if (missSb.length() >0) {
			result+= "缺失参数:"+missSb.toString()+". ";
		}
		
		if (invalidSb.length() >0) {
			result+= "无效的参数:"+invalidSb.toString();
		}
		return result;
	}
	
	
}
